package cn.com.xyzq.reks.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "staff_sell")
@XmlRootElement
public class StaffSell extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8569357272846049824L;

	private Long id;
	private Staff staff;
	private String code;
	private String codeName;
	private Double sellMoney;
	private Double deduct;
	private Integer sellPerson;
	private Date month;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	@ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST,
			CascadeType.MERGE })
	@JoinColumn(name = "staff_id")
	public Staff getStaff() {
		return staff;
	}

	@Column(name = "code", length = 20)
	public String getCode() {
		return code;
	}

	@Column(name = "code_name", length = 20)
	public String getCodeName() {
		return codeName;
	}

	@Column(name = "sell_money", precision = 20, scale = 2)
	public Double getSellMoney() {
		return sellMoney;
	}

	@Column(name = "deduct", precision = 20, scale = 2)
	public Double getDeduct() {
		return deduct;
	}

	@Column(name = "sell_person")
	public Integer getSellPerson() {
		return sellPerson;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "month", length = 10)
	public Date getMonth() {
		return month;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setCodeName(String codeName) {
		this.codeName = codeName;
	}

	public void setSellMoney(Double sellMoney) {
		this.sellMoney = sellMoney;
	}

	public void setDeduct(Double deduct) {
		this.deduct = deduct;
	}

	public void setSellPerson(Integer sellPerson) {
		this.sellPerson = sellPerson;
	}

	public void setMonth(Date month) {
		this.month = month;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
				.append("staff id", staff.getStaffId())
				.append("staff name", staff.getName()).append("code", code)
				.append("code Name", codeName).append("sell Money", sellMoney)
				.append("deduct", deduct).append("sell person", sellPerson)
				.append("month", month).toString();
	}

	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		if (this == o) {
			return true;
		}
		if (!(o instanceof StaffSell)) {
			return false;
		}
		final StaffSell ss1 = (StaffSell) o;
		return ss1.hashCode() == this.hashCode();
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		int result;
		result = (id != null ? id.hashCode() : 0);
		result = 29 * result + (staff != null ? staff.hashCode() : 0);
		result = 29 * result + (code != null ? code.hashCode() : 0);
		result = 29 * result + (codeName != null ? codeName.hashCode() : 0);
		result = 29 * result + (sellMoney != null ? sellMoney.hashCode() : 0);
		result = 29 * result + (deduct != null ? deduct.hashCode() : 0);
		result = 29 * result + (sellPerson != null ? sellPerson.hashCode() : 0);
		result = 29 * result + (month != null ? month.hashCode() : 0);
		return result;
	}

}
